/**
 * 
 */
package com.arx.character;

import com.arx.common.GlobalConsts;
import com.arx.interactive.InteractiveObject;

/**
 * @author Donald
 *
 */
public final class NPC extends NPCBehaviorBase {
	/** the singleton instance. */
	private static NPC	instance;
	/**
	 * Gets the one and only instance of {@link NPC}.
	 * @return {@link NPC}
	 */
	public static NPC getInstance() {
		if (NPC.instance == null) {
			NPC.instance = new NPC();
		}
		return NPC.instance;
	}
	/**
	 * Determines whether an {@link InteractiveObject} is a dead NPC.
	 * @param io the {@link InteractiveObject} NPC
	 * @return true if the {@link InteractiveObject} is an NPC whose life 
	 * is less than or equal to zero, or whose main event sets them to "DEAD"; 
	 * false otherwise
	 */
	public boolean IsDeadNPC(final InteractiveObject io) {
		boolean isDead = false;
		if (io != null && io.hasIoFlag(GlobalConsts.IO_NPC)) {
			if (io.getNpcdata() != null
					&& io.getNpcdata().getLife() <= 0) {
				isDead = true;
			} else if (io.getMainevent() != null
					&& io.getMainevent().equals("DEAD")) {
				isDead = true;
			}
		}
		return isDead;
	}
}
